package com.util;

import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class FanoutRabbitConfig {
    @Bean(name = "queue1")
    public Queue queue1() {
        return new Queue("fanout_queue1", false, false, false, null);
    }

    @Bean(name = "queue2")
    public Queue queue2() {
        return new Queue("fanout_queue2", false, false, false, null);
    }

    @Bean
    public FanoutExchange fanoutExchange() {
        return new FanoutExchange("fanout_exchange", false, false, null);
    }

    @Bean
    public Binding binding1(@Qualifier("queue1") Queue queue, FanoutExchange fanoutExchange) {
        return BindingBuilder.bind(queue).to(fanoutExchange);
    }

    @Bean
    public Binding binding2(@Qualifier("queue2") Queue queue, FanoutExchange fanoutExchange) {
        return BindingBuilder.bind(queue).to(fanoutExchange);
    }
}
